/**
 * https://ac.nowcoder.com/acm/problem/20076
 */

#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
using namespace std;
const int mm=1100000;
struct node{
    vector<int> m;
    int g;
}arr[mm];
int main()
{
    set<int> vp;
    int n,l;
    cin>>n>>l;
    int k;
    for(int i=1;i<=n;++i){
        cin>>k;
        arr[k].m.push_back(i);
        vp.insert(k);
    }
    int sum=0;
    for(auto t:vp){
        arr[t].g=1;
        int h=arr[t].m.size();
        for(int i=1;i<h;++i){
            if(arr[t].m[i]!=arr[t].m[i-1]+1)
                arr[t].g++;
        }
        sum+=arr[t].g;
    }
    while(l--){
        cin>>k;
        if(k==2){
            cout<<sum<<endl;
            continue;
        }
        int x,y;
        cin>>x>>y;
        if(x==y)
            continue;
        if(vp.find(y)!=vp.end()){
            for(auto b:arr[x].m)
                arr[y].m.push_back(b);
            sum=sum-arr[y].g-arr[x].g;
            arr[y].g=1;
            sort(arr[y].m.begin(),arr[y].m.end());
            int h=arr[y].m.size();
            for(int i=1;i<h;++i){
            if(arr[y].m[i]!=arr[y].m[i-1]+1)
                arr[y].g++;
            }
            sum+=arr[y].g;
        }
        else{
            arr[y].m=arr[x].m;
            arr[y].g=arr[x].g;
            vp.insert(y);
        }
        vp.erase(x);
        arr[x].m.clear();
    }
    return 0;
}